#include<iostream>
using namespace std;

int main()
{
    int x;
    char c;
    cin >> x >> c;
    int sum = 0;
    if(c=='y')
    {
        sum = sum + 5;
        if(x<=1000)
        {
            sum = sum + 8;
        }
        else
        {
            if((x-1000)%500==0)
            {
                sum = sum + 8 + (x-1000)/500*4 ;
            }
            else
            {
                sum = sum + 8 + ((x-1000)/500+1)*4;
            }
        }
    }
    else if(c=='n')
    {   
        if(x<=1000)
        {
            sum = sum + 8;
        }
        else if(x>1000)
        {
            if((x-1000)%500==0)
            {
                sum = sum + 8 + (x-1000)/500*4;
            }
            else
            {
                sum = sum + 8 + ((x-1000)/500+1)*4;
            }
        }
    }
    cout << sum << endl;
    return 0;
}